import Vue from 'vue'
import VueRouter from 'vue-router'
import State from '../views/State.vue'
import Home from '../views/Home.vue'
import Sort from '../views/Sort.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import User from '../views/User.vue'
import Address from '../views/Address'
import Addaddr from '../views/Addaddr'
import Addedit from '../views/Addedit'
import Lpkcart from '../views/Lpkcart'


Vue.use(VueRouter)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
   {
    path: '/state/:id',
    name:'State',
    component:State,
    props: true,
  },
  {
    path: '/home',
    name: 'Home',
    component:Home,
  },
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/list',
    name: 'List',
    component: () => import( /* webpackChunkName: "list" */ '../views/List.vue')

  },
   {
    path: '/addaddr',
    name: 'Addaddr',
    component: () => import( /* webpackChunkName: "list" */ '../views/Addaddr.vue')

  },
   {
    path: '/address',
    name: 'Address',
    component: () => import( /* webpackChunkName: "list" */ '../views/Address.vue')

  },
   {
    path: '/addedit',
    name: 'Addedit',
    component: () => import( /* webpackChunkName: "list" */ '../views/Addedit.vue')

  },
  {
    path: '/lpkcart',
    name: 'Lpkcart',
    component: () => import( /* webpackChunkName: "lpkcart" */ '../views/Lpkcart.vue')

  },

  {
    path: '/register',
    name: 'Register',
    component: () => import( /* webpackChunkName: "register" */ '../views/Register.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import( /* webpackChunkName: "login" */ '../views/Login.vue')
  },
  {
    path: '/user',
    name: 'User',
    component: () => import( /* webpackChunkName: "user" */ '../views/User.vue')

  },
  {
    path: '/products',
    name: 'Products',
    component: () => import( /* webpackChunkName: "products" */ '../views/Products.vue')

  },
  {
    path: '/state',
    name: 'State',
    component: State
  },
  {
    path: '/sort',
    name: 'Sort',
     component: () => import( /* webpackChunkName: "sort" */ '../views/Sort.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router